<template>
  <div class="search">
    <router-link tag="div" to="SearchTwo" class="search-box">
      <span class="iconfont icon-sousuo"><span></span> 青春</span>
    </router-link>
    <div class="grid"></div>
    <!-- 轮播图 -->
    <div class="bannerbox">
      <div class="swiper">
        <van-swipe class="my-swipe" @change="onChange" :autoplay="3000">
          <van-swipe-item v-for="item in genre.banners" :key="item.id">
            <img :src="item.cover + '?param=140y140'" />
          </van-swipe-item>
          <template #indicator>
            <div class="custom-indicator">{{ current + 1 }}/6</div>
          </template>
        </van-swipe>
      </div>
    </div>
    <!-- 创作人 -->
    <!-- <div class="composer">
      <ul>
        <li v-for="item in genre.recommended_position" :key="item.id">
          <div class="img">
            <img :src="item.icon" alt="" />
          </div>
          <p>{{ item.title }}</p>
        </li>
      </ul>
    </div> -->
    <div class="composer">
      <ul>
        <router-link tag="li" to="/ComposerFun">
          <div class="img">
            <img
              src="https://oss-xpc0.xpccdn.com/Upload/edu/2019/01/145c3c382f1a82d.png"
            />
          </div>
          <p>创作人</p>
        </router-link>
        <li>
          <div class="img">
            <img
              src="https://oss-xpc0.xpccdn.com/Upload/edu/2019/01/145c3c3871bd708.png"
            />
          </div>
          <p>机构</p>
        </li>
        <li>
          <div class="img">
            <img
              src="https://oss-xpc0.xpccdn.com/Upload/edu/2019/02/015c53c03cb6605.png"
            />
          </div>
          <p>正版教材</p>
        </li>
        <li>
          <div class="img">
            <img
              src="https://oss-xpc0.xpccdn.com/Upload/edu/2019/08/055d47e2511d1d8.png"
            />
          </div>
          <p>活动</p>
        </li>
      </ul>
    </div>
    <!-- 作品 -->
    <div class="works">
      <div class="works-top">
        <div class="left">作品</div>
        <div class="rigth">全部作品</div>
      </div>
      <div class="workslist">
        <ul>
          <li v-for="item in genre.categories" :key="item.id">
            <img :src="item.cover + '?param=140y140'" alt="" />
            <span>{{ item.category_name }}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { getdiscovery } from "../api/home";
export default {
  data() {
    return {
      current: 0,
      genre: "",
    };
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
    getdiscoveryFun() {
      getdiscovery().then((data) => {
        // console.log(data, "搜索页所有分类");
        this.genre = data.data;
        console.log(this.genre, "搜索页所有分类");
      });
    },
  },
  mounted() {
    this.getdiscoveryFun();
  },
};
</script>

<style lang="less" scoped>
.search {
  width: 100%;
  .search-box {
    width: 90%;
    height: 26px;
    line-height: 26px;
    margin: 10px auto;
    background-color: #f0f0f0;
    border-radius: 5px;
    span {
      font-size: 12px;
      margin-left: 12px;
      color: #999999;
    }
  }
  .grid {
    width: 100%;
    height: 2px;
    background-color: #e4e4e4;
  }
  //轮播图
  .bannerbox {
    width: 100%;
    text-align: center;
    margin-top: 10px;
    .swiper {
      margin: 0 auto;
      width: 93.6%;
      border-radius: 8px;
      overflow: hidden;
      position: relative;
      img {
        width: 100%;
      }
      // .custom-indicator {
      //   width: 100%;
      //   position: absolute;
      //   left: 0px;
      //   bottom: 0px;
      //   text-align: center;
      //   ul {
      //     display: inline-block;
      //     margin: 0 auto;
      //     li {
      //       display: inline-block;
      //       width: 6px;
      //       height: 2px;
      //       margin: 0px 2px;
      //       background: rgba(255, 255, 255, 0.6);
      //       &.con {
      //         background-color: #fff;
      //       }
      //     }
      //   }
      // }
      .my-swipe {
        display: flex;
        .custom-indicator {
          display: block;
          color: #fff;
          font-size: 12px;
          background: rgba(0, 0, 0, 0.1);
        }
      }
    }
  }
  //创作人
  .composer {
    width: 100%;
    ul {
      display: flex;
      justify-content: space-around;
      width: 100%;
      margin-top: 30px;
      li {
        width: 48px;
        display: flex;
        flex-direction: column;
        .img {
          width: 48px;
          height: 48px;
          box-shadow: 0px 3px 2px 2px #d3d0d0;
          border-radius: 50%;
          img {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            transform: scale(0.6);
          }
        }
        p {
          font-size: 12px;
          margin-top: 15px;
          text-align: center;
        }
      }
    }
  }
  //作品
  .works {
    width: 100%;
    .works-top {
      width: 100%;
      height: 18px;
      margin-top: 35px;
      margin-bottom: 20px;
      line-height: 18px;
      display: flex;
      justify-content: space-between;
      .left {
        font-size: 17px;
        margin-left: 15px;
      }
      .rigth {
        font-size: 12px;
        color: #df6456;
        margin-right: 15px;
      }
    }
    .workslist {
      width: 100%;
      ul {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        li {
          margin-left: 15px;
          width: 44%;
          height: 112px;
          background-color: #999999;
          margin-bottom: 18px;
          border-radius: 10px;
          position: relative;
          img {
            width: 100%;
            height: 112px;
            border-radius: 10px;
          }
          span {
            display: block;
            position: absolute;
            top: 12px;
            left: 10px;
            color: #fff;
            font-size: 14px;
          }
        }
      }
    }
  }
}
</style>